define(function(require, exports, module) {

	var $ = require('jquery');
	require('artTemplate/artTemplate/2.0.1/template.js');
	require('jquery/jquery-form/1.0.0/jquery.form.js');
	require('jquery/jquery-json/2.4.0/jquery.json.js');
	require('seajs/seajs/2.1.1/sea.js');
	require('jquery/jquery-validation/1.11.0/jquery.validate');
	require('jquery/jquery-validation/1.11.0/messages_zh');
	require('jbox');
	
	exports.options = {
		listLink : '',
		listParams : '',
		pageLink : '',
		pageParams : ''
	};
	
	$("#sendmessage-form").validate({
		rules : {
			content:{
				required:true,
			},
		},
		messages : {
			content:{
				required:function(){
					$.jBox.tip("您还没有天消息内容呢!");
				},
			},
		},
	});
	
	$('.add-submit').click(function(){
		if(!$("#sendmessage-form").valid()){
			return;
		}
		var postData = form2js('sendmessage-form', '.', true);
		postData.messageFrom={"id":g_user.id};
		//console.log($.toJSON(postData));
		$.ajax({
			url : $CONFIG.base_url + "/api/message/add",
			type : "POST",
			data : $.toJSON(postData),
			dataType : "json",
			contentType : "application/json",
			success : function() {
				$.jBox.tip("发送消息成功！");
				setTimeout(function(){window.location.href=$CONFIG.base_url + '/'+$CONFIG.admin_url+'/user/list';;},1000);
			},
			error : function() {
				$.jBox.tip("发送消息失败！");
			}
		});
	});
});